<!DOCTYPE html>

<html>
<head>
<meta content="text/html; charset=CP852" http-equiv="Content-Type">

<title>class Collection - RDoc Documentation</title>

<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">

<script type="text/javascript">
  var rdoc_rel_prefix = "./";
</script>

<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>


<body id="top" class="class">
<nav id="metadata">
  <nav id="home-section" class="section">
  <h3 class="section-header">
    <a href="./index.html">Home</a>
    <a href="./table_of_contents.html#classes">Classes</a>
    <a href="./table_of_contents.html#methods">Methods</a>
  </h3>
</nav>


  <nav id="search-section" class="section project-section" class="initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <h3 class="section-header">
      <input type="text" name="search" placeholder="Search" id="search-field"
             title="Type to search, Up and Down to navigate, Enter to load">
    </h3>
  </form>

  <ul id="search-results" class="initially-hidden"></ul>
</nav>


  <div id="file-metadata">
    <nav id="file-list-section" class="section">
  <h3 class="section-header">Defined In</h3>
  <ul>
    <li>lib/collection.rb
  </ul>
</nav>

    
  </div>

  <div id="class-metadata">
    
    <nav id="parent-class-section" class="section">
  <h3 class="section-header">Parent</h3>
  
  <p class="link">Object
  
</nav>

    
    <!-- Method Quickref -->
<nav id="method-list-section" class="section">
  <h3 class="section-header">Methods</h3>

  <ul class="link-list">
    
    <li><a href="#method-c-new">::new</a>
    
    <li><a href="#method-i-5B-5D">#[]</a>
    
    <li><a href="#method-i-docs">#docs</a>
    
    <li><a href="#method-i-documents">#documents</a>
    
    <li><a href="#method-i-load">#load</a>
    
    <li><a href="#method-i-to_s">#to_s</a>
    
  </ul>
</nav>

  </div>

  <div id="project-metadata">
    <nav id="fileindex-section" class="section project-section">
  <h3 class="section-header">Pages</h3>

  <ul>
  
    <li class="file"><a href="./LICENSE.html">LICENSE</a>
  
    <li class="file"><a href="./README.html">README</a>
  
    <li class="file"><a href="./Rakefile.html">Rakefile</a>
  
    <li class="file"><a href="./nbproject/private/rake-d_txt.html">rake-d</a>
  
  </ul>
</nav>

    <nav id="classindex-section" class="section project-section">
  <h3 class="section-header">Class and Module Index</h3>

  <ul class="link-list">
  
    <li><a href="./Collection.html">Collection</a>
  
    <li><a href="./Document.html">Document</a>
  
    <li><a href="./ExistAPI.html">ExistAPI</a>
  
    <li><a href="./ExistException.html">ExistException</a>
  
    <li><a href="./TestExistAPI.html">TestExistAPI</a>
  
  </ul>
</nav>

  </div>
</nav>

<div id="documentation">
  <h1 class="class">class Collection</h1>

  <div id="description" class="description">
    
  </div><!-- description -->

  
  
  
  <section id="5Buntitled-5D" class="documentation-section">
    

    

    

    
    <!-- Attributes -->
    <section id="attribute-method-details" class="method-section section">
      <h3 class="section-header">Attributes</h3>

      
      <div id="attribute-i-childCollection" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">childCollection</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-group" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">group</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-name" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">name</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-owner" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">owner</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
      <div id="attribute-i-permissions" class="method-detail">
        <div class="method-heading attribute-method-heading">
          <span class="method-name">permissions</span><span
            class="attribute-access-type">[R]</span>
        </div>

        <div class="method-description">
        
        
        
        </div>
      </div>
      
    </section><!-- attribute-method-details -->
    

    <!-- Methods -->
    
     <section id="public-class-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Class Methods</h3>

    
      <div id="method-c-new" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">new</span><span
            class="method-args">(client, collectionName)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Creates new collection.</p>

<pre>* *Args*    :
  - +client+ -&gt; e.g. ExistAPI.new(&quot;http://localhost:8080/exist/xmlrpc&quot;, &quot;admin&quot;, &quot;password&quot;)    
  - +collectionName+ -&gt; /db/data/cities/
* *Returns* :
  -new instance of collection
* *Raises* :
  - +nothing+ -&gt;</pre>
          

          
          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/collection.rb, line 22</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">initialize</span>(<span class="ruby-identifier">client</span>, <span class="ruby-identifier">collectionName</span>)
  <span class="ruby-ivar">@client</span> = <span class="ruby-identifier">client</span>
  <span class="ruby-identifier">load</span>(<span class="ruby-identifier">collectionName</span>)
<span class="ruby-keyword">rescue</span>  =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>  
<span class="ruby-keyword">end</span></pre>
          </div><!-- new-source -->
          
        </div>

        

        
      </div><!-- new-method -->

    
    </section><!-- public-class-method-details -->
  
     <section id="public-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Public Instance Methods</h3>

    
      <div id="method-i-5B-5D" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">[]</span><span
            class="method-args">(key)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns instance of collection's child specified by name.</p>

<pre>* *Args*    :
  - +key+ -&gt; name of the child
* *Returns* :
  -instance of collection's child (document or collection)
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="5B-5D-source">
            <pre><span class="ruby-comment"># File lib/collection.rb, line 79</span>
<span class="ruby-keyword">def</span> <span class="ruby-operator">[]</span>(<span class="ruby-identifier">key</span>)
  <span class="ruby-ivar">@documents</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">d</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">key</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">name</span> 
  }
  <span class="ruby-keyword">return</span> <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- 5B-5D-source -->
          
        </div>

        

        
      </div><!-- 5B-5D-method -->

    
      <div id="method-i-docs" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">docs</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns string array of all documents in collection</p>

<pre>* *Args*    :
  - +none+
* *Returns* :
  -array of strings
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="docs-source">
            <pre><span class="ruby-comment"># File lib/collection.rb, line 64</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">docs</span>    
  <span class="ruby-identifier">ds</span> = []
  <span class="ruby-ivar">@documents</span>.<span class="ruby-identifier">each</span>{ <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">ds</span>.<span class="ruby-identifier">push</span>(<span class="ruby-identifier">d</span>.<span class="ruby-identifier">name</span>)}
  <span class="ruby-keyword">return</span> <span class="ruby-identifier">ds</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- docs-source -->
          
        </div>

        

        
      </div><!-- docs-method -->

    
      <div id="method-i-documents" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">documents</span><span
            class="method-args">() { |d| ... }</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Yield each document from collection.</p>

<pre>* *Args*    :
  - +none+
* *Returns* :
  -documents
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="documents-source">
            <pre><span class="ruby-comment"># File lib/collection.rb, line 51</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">documents</span>
  <span class="ruby-ivar">@documents</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-keyword">yield</span> <span class="ruby-identifier">d</span> }
<span class="ruby-keyword">end</span></pre>
          </div><!-- documents-source -->
          
        </div>

        

        
      </div><!-- documents-method -->

    
      <div id="method-i-to_s" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">to_s</span><span
            class="method-args">()</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Returns string of collection. That inclunde permissions, owner, group and
name.</p>

<pre>* *Args*    :
  - +none+
* *Returns* :
  -string of collection
* *Raises* :
  - +nothing+</pre>
          

          
          <div class="method-source-code" id="to_s-source">
            <pre><span class="ruby-comment"># File lib/collection.rb, line 38</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">to_s</span>()
  <span class="ruby-keyword">return</span> <span class="ruby-node">&quot;#{@permissions} #{@owner} #{@group} #{@name}&quot;</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- to_s-source -->
          
        </div>

        

        
      </div><!-- to_s-method -->

    
    </section><!-- public-instance-method-details -->
  
     <section id="protected-instance-5Buntitled-5D-method-details" class="method-section section">
      <h3 class="section-header">Protected Instance Methods</h3>

    
      <div id="method-i-load" class="method-detail ">
        
        <div class="method-heading">
          <span class="method-name">load</span><span
            class="method-args">(collectionName)</span>
          <span class="method-click-advice">click to toggle source</span>
        </div>
        

        <div class="method-description">
          
          <p>Loads collection from db.</p>

<pre>* *Args*    :
  - +collectionName+ -&gt; e.g. /db/data/cities/
* *Returns* :
  - instance of collection
* *Raises* :
  - +ExistException+ -&gt; Failed to load Collection</pre>
          

          
          <div class="method-source-code" id="load-source">
            <pre><span class="ruby-comment"># File lib/collection.rb, line 97</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier">load</span>(<span class="ruby-identifier">collectionName</span>)
  <span class="ruby-identifier">resp</span> = <span class="ruby-ivar">@client</span>.<span class="ruby-identifier">call</span>(<span class="ruby-string">&quot;getCollectionDesc&quot;</span>, <span class="ruby-identifier">collectionName</span>)
  <span class="ruby-ivar">@name</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-string">'name'</span>]<span class="ruby-operator">+</span><span class="ruby-string">&quot;/&quot;</span>
  <span class="ruby-ivar">@owner</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-string">'owner'</span>]
  <span class="ruby-ivar">@group</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-string">'group'</span>]
  <span class="ruby-ivar">@permissions</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-string">'permissions'</span>]
  <span class="ruby-ivar">@childCollection</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-string">'collections'</span>]
          
  <span class="ruby-ivar">@documents</span> = <span class="ruby-constant">Array</span>.<span class="ruby-identifier">new</span>
  <span class="ruby-identifier">docs</span> = <span class="ruby-identifier">resp</span>[<span class="ruby-string">'documents'</span>]
  <span class="ruby-comment">#puts &quot;docs #{docs}&quot;</span>
  <span class="ruby-identifier">docs</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-ivar">@documents</span>.<span class="ruby-identifier">push</span>(<span class="ruby-constant">Document</span>.<span class="ruby-identifier">new</span>(<span class="ruby-ivar">@client</span>, <span class="ruby-identifier">d</span>, <span class="ruby-ivar">@name</span>)) }
<span class="ruby-keyword">rescue</span> <span class="ruby-constant">XMLRPC</span><span class="ruby-operator">::</span><span class="ruby-constant">FaultException</span> =<span class="ruby-operator">&gt;</span> <span class="ruby-identifier">e</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-identifier">e</span>
<span class="ruby-keyword">rescue</span>
  <span class="ruby-identifier">raise</span> <span class="ruby-constant">ExistException</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">&quot;Failed to load Collection&quot;</span>, <span class="ruby-value">10</span>), <span class="ruby-identifier">callers</span>
<span class="ruby-keyword">end</span></pre>
          </div><!-- load-source -->
          
        </div>

        

        
      </div><!-- load-method -->

    
    </section><!-- protected-instance-method-details -->
  
  </section><!-- 5Buntitled-5D -->

</div><!-- documentation -->


<footer id="validator-badges">
  <p><a href="http://validator.w3.org/check/referer">[Validate]</a>
  <p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 3.12.
  <p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
</footer>

